<?php
!defined('P_W') && exit('Forbidden');
define('AREA_SCR','image_xml');
InitGP(array('id'),'',2);
$imageService = House::loadClass('houseimage'); /* @var $imageService PW_HouseImage */
$image = $imageService->getImage($id);
$typeid = $image['typeid'];
if (!$image) Showmsg('undefined_action');

	$imageTypeService = House::loadClass('houseimagetype'); /* @var $imageTypeService PW_HouseImageType */
$imageType = $imageTypeService->getType($typeid);
if (!$imageType) Showmsg('undefined_action');
$topid = $imageType['sub'] ? (int) $imageType['sub'] : $typeid;

$topTypes = $imageTypeService->getTopTypes();
$secendTypes = $imageTypeService->getSecendTypesById($topid);

if ($secendTypes) {
	$searchTypeid = array_keys($secendTypes);
	$searchTypeid[] = $typeid;
} else {
	$searchTypeid = $typeid;
}

$images = $imageService->getImages($image['hid'],$searchTypeid,'all');

$temp = '<?xml version="1.0" encoding="utf-8"?>'."<album>";
foreach ($images as $key=>$value) {
	$descrip = pwConvert($value['descrip'], 'utf-8', $db_charset);
	$temp .= "<p id=\"$key\">";
	$temp .= '<t>'.$db_bbsurl.'/'.$value['mini'].'</t>';
	$temp .= '<n>'.$descrip.'</n>';
	$temp .= '<l>'.$value['path'].'</l>';
	$temp .= '</p>';
}
$temp .= '</album>';

echo $temp;exit;
?>